<template>
    <div>
        <div class="form-item form-item-style1">
            <div class="label-title">
                <label>单位名称</label>
            </div>
            <div>
                <p>{{detailData.ParentName}}</p>
            </div>
        </div>
        <div class="form-item form-item-style1">
            <div class="label-title">
                <label>项目名称</label>
            </div>
            <div>
                <p>{{detailData.ProjectName}}</p>
            </div>
        </div>
        <div class="form-item form-item-style1">
            <div class="label-title">
                <label>设备类型</label>
            </div>
            <div>
                <p>{{detailData.EquipmentTypeName}}</p>
            </div>
        </div>
        <div class="form-item form-item-style1">
            <div class="label-title">
                <label>自编号</label>
            </div>
            <div>
                <p>{{detailData.EquipmentNo}}</p>
            </div>
        </div>
        <div class="form-item form-item-style1">
            <div class="label-title">
                <label>设备型号</label>
            </div>
            <div>
                <p>{{detailData.EquipmentModeNo}}</p>
            </div>
        </div>
        <div class="form-item form-item-style1">
            <div class="label-title">
                <label>备案编号</label>
            </div>
            <div>
                <p>{{detailData.EquipmentRecordNo}}</p>
            </div>
        </div>
        <div class="form-item form-item-style1">
            <div class="label-title">
                <label>安装位置</label>
            </div>
            <div>
                <p>{{detailData.SetupLocation}}</p>
            </div>
        </div>
        <div class="form-item form-item-style1">
            <div class="label-title">
                <label>进场日期</label>
            </div>
            <div>
                <p>{{detailData.EntryDate?detailData.EntryDate.split(' ')[0]:''}}</p>
            </div>
        </div>
        <div class="form-item form-item-style1">
            <div class="label-title">
                <label>安装日期</label>
            </div>
            <div>
                <p>{{detailData.SetupDate?detailData.SetupDate.split(' ')[0]:''}}</p>
            </div>
        </div>
        <div class="form-item form-item-style1">
            <div class="label-title">
                <label>退场日期</label>
            </div>
            <div>
                <p>{{detailData.OutDate?detailData.OutDate.split(' ')[0]:''}}</p>
            </div>
        </div>
        <div class="form-item form-item-style1">
            <div class="label-title">
                <label>检测日期</label>
            </div>
            <div>
                <p>{{detailData.CheckDate?detailData.CheckDate.split(' ')[0]:''}}</p>
            </div>
        </div>
        <div class="form-item form-item-style1">
            <div class="label-title">
                <label>使用登记有效日期</label>
            </div>
            <div>
                <p>{{detailData.UseValidateTo?detailData.UseValidateTo.split(' ')[0]:''}}</p>
            </div>
        </div>
        <div class="form-item form-item-style1">
            <div class="label-title">
                <label>是否在场</label>
            </div>
            <div>
                <p>{{detailData.IsInPresence}}</p>
            </div>
        </div>
        <div class="form-item form-item-style1">
            <div class="label-title">
                <label>是否自有设备</label>
            </div>
            <div>
                <p>{{detailData.IsSelfEquipment}}</p>
            </div>
        </div>
        <div class="form-item form-item-style1">
            <div class="label-title">
                <label>安装单位</label>
            </div>
            <div>
                <p>{{detailData.SetupUint}}</p>
            </div>
        </div>
        <div class="form-item form-item-style1">
            <div class="label-title">
                <label>产权单位</label>
            </div>
            <div>
                <p>{{detailData.CopyRightName}}</p>
            </div>
        </div>
        <div class="cut-off-rule"></div>
        <div class="form-section">
            <h3>操作人员信息</h3>
            <ul class="list1">
                <li v-for="(item,index) in detailData.OperationList"
                    :key="index">
                    <router-link :to='{path:"/operatingPersonnel",query:{id:item.ID}}'>
                        <div>
                            <p>姓名：{{item.UserName}}</p>
                            <p>证件有效期：{{item.PaperValidateTo?item.PaperValidateTo.split(' ')[0]:''}}</p>
                        </div>
                        <div class="right-section">
                            <span>{{item.JobName}}</span>
                            <x-icon type="ios-arrow-right"
                                    size="20"
                                    class="icon-right"></x-icon>
                        </div>
                    </router-link>
                </li>
            </ul>
        </div>
        <div class="cut-off-rule"></div>
        <div class="form-section">
            <h3>检测合格报告</h3>
            <div class="form-item form-item-style1"
                 v-for="(item,index) in detailData.CheckList"
                 :key="index"
                 @click="preview(item.FileFullName)">
                <div class="label-title label-title1">
                    <label>附件</label>
                </div>
                <div class="right-section">
                    <span>预览</span>
                    <x-icon type="ios-arrow-right"
                            size="20"
                            class="icon-right"></x-icon>
                </div>
            </div>
        </div>
        <div class="cut-off-rule"></div>
        <div class="form-section">
            <h3>使用登机牌</h3>
            <div class="form-item form-item-style1"
                 v-for="(item,index) in detailData.UseList"
                 :key="index"
                 @click="preview(item.FileFullName)">
                <div class="label-title label-title1">
                    <label>附件</label>
                </div>
                <div class="right-section">
                    <span>预览</span>
                    <x-icon type="ios-arrow-right"
                            size="20"
                            class="icon-right"></x-icon>
                </div>
            </div>
        </div>
        <div class="cut-off-rule"></div>
        <div class="form-section">
            <h3>租赁合同</h3>
            <div class="form-item form-item-style1"
                 v-for="(item,index) in detailData.RentList"
                 :key="index"
                 @click="preview(item.FileFullName)">
                <div class="label-title label-title1">
                    <label>附件</label>
                </div>
                <div class="right-section">
                    <span>预览</span>
                    <x-icon type="ios-arrow-right"
                            size="20"
                            class="icon-right"></x-icon>
                </div>
            </div>
        </div>
        <div class="cut-off-rule"></div>
        <div class="form-section">
            <h3>设备安全技术档案</h3>
            <ul class="list2">
                <!-- <li>
                    <router-link to="/wisdomStandingBook">
                        <p>安拆方案</p>
                        <x-icon type="ios-arrow-right"
                                size="20"
                                class="icon-right"></x-icon>
                    </router-link>
                </li> -->
                <li>
                    <router-link :to="{path:'/checkRecord',query:{
                        ProjectId:detailData.ProjectID,
                        EquipmentNo: detailData.EquipmentNo,
                        EquipmentTypeNo: detailData.EquipmentTypeNo
                    }}">
                        <p>进场验收记录</p>
                        <x-icon type="ios-arrow-right"
                                size="20"
                                class="icon-right"></x-icon>
                    </router-link>
                </li>
                <li>
                    <router-link :to="{path:'/installRecord',query:{
                        ProjectId:detailData.ProjectID,
                        EquipmentNo: detailData.EquipmentNo,
                        EquipmentTypeNo: detailData.EquipmentTypeNo
                    }}">
                        <p>安装验收记录</p>
                        <x-icon type="ios-arrow-right"
                                size="20"
                                class="icon-right"></x-icon>
                    </router-link>
                </li>
                <li>
                    <router-link :to="{path:'/maintainRecord',query:{
                        ProjectId:detailData.ProjectID,
                        EquipmentNo: detailData.EquipmentNo,
                        EquipmentType: detailData.EquipmentTypeName
                    }}">
                        <p>维护保养记录</p>
                        <x-icon type="ios-arrow-right"
                                size="20"
                                class="icon-right"></x-icon>
                    </router-link>
                </li>
                <li>
                    <router-link :to="{path:'/clearCheckRecord',query:{
                        ProjectId:detailData.ProjectID,
                        EquipmentNo: detailData.EquipmentNo,
                        EquipmentTypeNo: detailData.EquipmentTypeNo
                    }}">
                        <p>设备拆除前检查记录</p>
                        <x-icon type="ios-arrow-right"
                                size="20"
                                class="icon-right"></x-icon>
                    </router-link>
                </li>
                <li>
                    <router-link :to="{path:'/inspectionRecord',query:{
                        Id:detailData.ID
                    }}">
                        <p>设备日常检查记录</p>
                        <x-icon type="ios-arrow-right"
                                size="20"
                                class="icon-right"></x-icon>
                    </router-link>
                </li>
            </ul>
            <div class="btns"
                 v-if="haveBtn">
                <!-- <button>保存</button> -->
                <button class="green width200"
                        @click="handleSubmit">开始安全检查</button>
            </div>
            <myMenu></myMenu>
        </div>
    </div>
</template>
<script>
import upload from '@/commonComponents/upload/index'
import myMenu from '@/commonComponents/menu'
export default {
    name: 'equipmentDetails',
    components: {
        upload,
        myMenu
    },
    data () {
        return {
            imgList: [],
            YSFormData: '',
            uploadLength: 0,
            userInfo: '',
            detailData: {},
            regImg: /\.(png|jpg|PNG|JPG|jpeg|JPEG|gif|GIF)$/,
            haveBtn: false
        }
    },
    created () {
        this.userInfo = JSON.parse(localStorage.getItem('userInfo')) || {}
        this.haveBtn = this.$route.query.haveBtn
        this.getDetail()
    },
    methods: {
        preview (filePath) {
            if (this.regImg.test(filePath)) {
                this.$router.push({
                    path: '/previewImg',
                    query: {
                        previewImg: filePath
                    }
                })
            } else {
                wx.miniProgram.navigateTo({
                    url: `/pages/openDocument/index?filePath=${filePath}`
                })
            }
        },
        getDetail () {
            this.$vux.loading.show({
                text: '加载中...'
            })
            let params = {
                'allowPaging': true,
                'business': 'getSpecialEquipmentDetail',
                'data': {
                    id: this.$route.query.id
                },
                'userId': this.userInfo.userid
            }
            this.$axiosAjax.getConfigJson(params).then((res) => {
                if (res.data.code === 0) {
                    this.detailData = res.data.data
                    this.detailData.UseList.forEach(item => {
                        this.imgList.push(item.FileFullName)
                    })
                }
            }).catch(() => {

            }).finally(() => {
                this.$vux.loading.hide()
            })
        },
        handleSubmit () {
            this.$router.push({
                path: '/testing',
                query: {
                    id: this.$route.query.id
                }
            })
        }
    }
}
</script>
<style scoped>
.list2 {
    background: #fff;
}
</style>
